﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

using Tradex.ComponentModel;

namespace Tradex.Trading {

    /// <summary>
    /// The AccountKey uniquely identified an account within the Tradex system.
    /// </summary>
    [Serializable()]
    public class AccountKey : Key<Account> {

        /// <summary>
        /// Public Constructor taking all values.
        /// </summary>
        /// <param name="broker"></param>
        /// <param name="subBroker"></param>
        /// <param name="account"></param>
        public AccountKey(string broker, string subBroker, string account) {
            if (String.IsNullOrEmpty(subBroker)) {
                Account = String.Format (CultureInfo.InvariantCulture, "{0}/{1}", broker, account);
            } else {
                Account = String.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}", broker, subBroker, account);
            }
        }

        /// <summary>
        /// Gets the account.
        /// </summary>
        public string Account { get; private set; }

        /// <inheritdoc />
        public override string ToString() {
            return Account;
        }

    }

}
